Terrain · Landform Classification
TPI – Topographic Position Index
TPI (Topographic Position Index) compares each cell's elevation to the mean elevation
of its neighborhood to distinguish ridges, valleys and slopes from a DEM.
1. Scientific Definition
The Topographic Position Index (TPI) is defined as the difference between
the elevation of a cell and the mean elevation of its surrounding neighborhood.
Formula
TPI = Elevationcell − mean(Elevationneighbors )
Elevationcell – height of the target pixel
mean(Elevationneighbors ) – average height in a window (e.g. 3×3, 5×5, radius in meters)
Interpretation
TPI > 0 → ridge / upper slope (higher than surroundings)
TPI ≈ 0 → mid-slope / flat
TPI < 0 → valley / lower slope (lower than surroundings)
Applications
Landform classification (ridge, valley, slope)
Habitat and ecological niche analysis
Hydrology and erosion studies
Site selection and geomorphology mapping
2. Data Requirements
Elevation Data (DEM)
SRTM – "CGIAR/SRTM90_V4" أو "USGS/SRTMGL1_003"
Copernicus DEM – "COPERNICUS/DEM/GLO30"
Any high-resolution DEM available for the area
Neighborhood (Scale)
Small window (e.g. radius 250–500 m) → micro landforms
Large window (e.g. radius 1–2 km) → macro landforms
Suggested Palette
[
"#313695", "#74add1", "#f0f0f0",
"#f46d43", "#a50026"
]
3. Google Earth Engine Code – TPI from DEM
Copy Code
// TPI – Topographic Position Index
// TPI = Elevation_cell - mean(Elevation_neighbors)
// AOI
var roi = geometry;
Map.centerObject(roi, 9);
// 1. Load DEM (example: Copernicus DEM 30m)
var dem = ee.Image("COPERNICUS/DEM/GLO30")
.select("DEM")
.clip(roi);
// 2. Define neighborhood radius (in meters)
// e.g. 500 m ~ local landform
var radius = 500;
// Convert radius (meters) to kernel in pixels using nominal scale
var scale = dem.projection().nominalScale();
var kernelRadius = radius / scale;
// 3. Compute mean elevation of neighborhood
var meanNeigh = dem.focal_mean({
radius: kernelRadius,
units: "pixels",
kernelType: "circle"
}).rename("DEM_mean");
// 4. Compute TPI
var tpi = dem.subtract(meanNeigh).rename("TPI");
// 5. Visualization
var vis = {
min: -50,
max: 50,
palette: [
"#313695", // deep valleys
"#74add1",
"#f0f0f0", // mid-slope / flat
"#f46d43",
"#a50026" // high ridges
]
};
Map.addLayer(tpi, vis, "TPI (Topographic Position Index)");
// 6. Optional landform classification (simple)
// Example thresholds (can be refined):
// TPI < -15 → valley
// -15 to 15 → mid-slope / flat
// TPI > 15 → ridge
var valley = tpi.lt(-15).selfMask().rename("Valley");
var ridge = tpi.gt(15).selfMask().rename("Ridge");
Map.addLayer(valley, {palette:["#313695"]}, "Valleys (TPI < -15)", false);
Map.addLayer(ridge, {palette:["#a50026"]}, "Ridges (TPI > 15)", false);
// 7. Export TPI
Export.image.toDrive({
image: tpi,
description: "TPI_export",
fileNamePrefix: "TPI_DEM",
region: roi,
scale: 30,
crs: "EPSG:4326",
maxPixels: 1e13
});
TPI – Topographic Position Index · Start4IT Terrain & Landform Library